<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>修改</title>
        <link rel="stylesheet" href="/css/bootstrap.min.css">
        <link rel="stylesheet" href="/css/add.css">
        <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css">
    </head>
    <body>
        <nav class="navbar navbar-default">
            <div class="container">
                <div class="navbar-header">
                    <a class="navbar-brand" href="/user/main">
                        科室管理
                    </a>
                </div>
            </div>
        </nav>
        <div class="container">
            <div class="page-header">
                <h3><small>修改</small></h3>
            </div>
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">名称：</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" id="name" value="${category.name}" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                    <input type="text" id="dd" value="${category.id}" hidden>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">选择框：</label>
                    <div class="layui-input-block">
                        <select name="id" id="id" lay-verify="required">
                            <option value="">${category.categoryId}</option>
                            <option value="内科">内科</option>
                            <option value="外科">外科</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="formDemo">修改</button>
                    </div>
                </div>
            </form>

        </div>
        <script src="/layuiadmin/layui/layui.js"></script>
        <script>
            layui.config({
                base: '/layuiadmin/' //静态资源所在路径
            }).extend({
                index: 'lib/index' //主入口模块
            }).use(['index', 'user','jquery','layer'], function(){
                var $ = layui.$
                    ,setter = layui.setter
                    ,admin = layui.admin
                    ,form = layui.form
                    ,router = layui.router()
                    ,layer=layui.layer
                    ,jquery=layui.jquery
                    ,search = router.search;
                form.render();

                //提交
                form.on('submit(formDemo)', function(obj){
                   var name=$("#name").val();
                   var id=$("#id").val();
                   var dd=$("#dd").val();
                   $.ajax({
                      url:"/cate/update",
                      data:{"categoryId":id,"name":name,"id":dd},
                      success:function (result) {
                          if(result=="success"){
                              layer.msg("修改成功",{
                                  icon:1,
                                  time:1000
                                  },function () {
                                  location.href="/cate/hello";
                              });
                          }
                      },
                      error:function (errorMsg) {
                          alert("错误");
                      }
                   });
                   /* $.ajax({
                        url:"/cate/add",
                        data:{"id":id,"password":password},
                        success:function (result) {
                            if(result=="success"){
                                layer.msg("登录成功",{
                                    offset:'15px'
                                    ,icon:1
                                    ,time:2000
                                }, function () {
                                    location.href="/user/main";
                                });
                            }
                            if(result=="error"){
                                layer.msg("用户名或则密码错误");

                            }
                        },
                        error:function (errorMsg) {
                            alert("出错了");
                        }
                    });*/
                    return false;
                });


            });
        </script>
    </body>
</html>
